home *** CD-ROM | disk | FTP | other *** search
- Data Input Validation
- =====================
- Type validation
- ===============
- By this term we mean the exercising of control over what characters a field
- will accept. RISC OS provides the means to allow writable icons to accept
- only certain characters, or ranges of characters, and reject others. The
- disallowed characters are simply ignored so that attempts to type them have
- no effect.
-
- If you open Powerbase's own application directory (SHIFT/double-click) you
- will find a file called 'ValStrings'. You are recommended not to alter this
- file unless you understand exactly what you are doing and, if you do so, to
- keep a copy of the original. Examining it, however, can give you an insight
- into the validation process. Look, for example, at the entry "03 Number".
- This refers to field type 3 (numeric). The line below is the validation
- string of the writable icon which makes up a numeric field. It looks like
- this:-
- Pptr_write,4,4;A0-9.+\-
-
- The intial 'P' is a command and signifies "pointer". 'ptr_write' is the name
- of the sprite used to represent the mouse pointer when it is over this type
- (and many other types) of field. You will have noticed that the usual RISC
- OS arrow changes to a blue vertical bar, somewhat resembling the caret, when
- over a writable field. '4,4' specifies the "active point" of the pointer.
- The next character is a semicolon which indicates that a new command
- follows.
-
- The 'A' which comes next is the command "allow" and is the part of the
- validation string which especially concerns us. It determines what
- characters the field will allow you to type. In this case they are the
- numerals 0-9, the decimal point and the plus and minus signs. Why the back-
- slash before the latter? Because '-' is a special character in an icon
- validation string (used, as in this case, to specify a range of characters)
- and so are the semicolon, tilde (~) and the backslash itself. To include any
- of these four characters in the validation string you must precede it with a
- backslash.
-
- A couple of further examples should be sufficient. "01 Alphanumeric" uses
- the same pointer type but the characters accepted are <space> (immediately
- after the 'A' for "allow"), the upper-case letters A-Z, the lower-case
- letters a-z, the numerals 0-9, some common punctuation and the "half"
- character. You might want to add to this list. "06 Calculated" uses a
- different pointer sprite (ptr_calc, which resembles a pocket calculator) and
- has no "allow" command at all: it doesn't need one because you can't type
- into this type of field, whose value is calculated from other fields.
-
- Table validation
- ================
- This level of validation only comes into effect after entering data in a
- field which is linked to a validation table. Such fields are recognizable by
- having their text dark green instead of black. When you click the mouse over
- a new field or type RETURN, the linked validation table is scanned to see
- whether what you entered in the field occurs in the table. If it doesn't
- then Powerbase will restore the previous contents of the field and print an
- error message.
-
- Validation tables should be used whenever the contents of a field have to
- conform to certain "values". A manufacturing company will have a product
- code for every item which it makes and a database of customers which the
- firm supplies will make use of such codes to identify the items. It is
- essential that whoever enters the data is prevented from accidentally typing
- a spurious code. By linking the appropriate field to a validation table
- containing all the valid codes such mistakes can be prevented. Moreover, the
- validation table can also contain other data about the products, such as a
- name and a brief description, and lists can be printed in which this more
- understandable data appears instead of the cryptic codes. Up to nine items
- of data could be associated with each product code.
-
- The F.E. college database referred to in 'BrowseEdit' ("Using more than one
- subfile") makes extensive use of validation tables for subjects, courses,
- tutors and schools of origin. Not only does this trap typing errors but the
- data entry is greatly speeded up when one can type 'ELL' instead of 'English
- Language and Literature', yet have the latter printed out in full on a list
- or a timetable if one wishes.
-
- A further option with validation tables is to have Powerbase replace the
- typed-in code with a longer, more readable, form immediately on entry.
- Provided the substitute data will fit in the field the replacement occurs
- when you type RETURN or click the mouse in another field. If the replacement
- is too long then the typed-in data will be unchanged.
-
- The maximum number of validation tables is 20 and is determined by the text
- file 'Config' within the 'Resources' subdirectory in the Powerbase directory.
-
- Creating a validation table
- ===========================
- Choose 'Create table' from the 'Validation' submenu. Give the table a
- suitable name and enter the number of rows required. This will be the
- maximum number of values the table can contain. Always be generous in your
- estimates; tables can't be extended later. The next item required is the
- highest column number in the table. A maximum of 10 columns, with numbering
- from 0-9, is allowed.
-
- The most common situation is to have two columns. The first holds the short
- code which specifies what may be typed into the linked record field. The
- second is an expansion or explanation of the former. Define the maximum
- length of each field in the table and give each one a heading. Don't forget
- that the heading has to fit within whatever column width the field length
- will allow. There will only be single spaces between the columns.
-
- When you are satisfied with the data click 'OK' and the table will be
- created in memory. It is not saved on disc at this stage. You may enter
- data into it now or later. Entries may be freely altered and overwritten but
- do not forget to save the table whenever changes have been made.
-
- Linking tables to fields
- ========================
- To link a validation table to a field the table must be in memory . Click
- MENU over the required data field and follow the 'Field' submenu, choosing
- the 'Link to table' option.
-
- A pair of "bump icons" permits you to cycle through the tables in memory. A
- menu, displayed by clicking SELECT or MENU over the right-pointing arrow to
- the right of the table name, provides an alternative way of choosing a
- table. When you have the name of the required one displayed choose the
- column of the table to which the field is to be linked. It is recommended
- that column 0 should normally provide the link (and therefore contain the
- data items which may be actually entered on the records) and this is set by
- default. You may, however, link to any column in the table and a second pair
- of "bump icons" allows you to cycle throught the column numbers.
-
- If you want the "replace on entry" option described previously then select
- the option switch for this. A third set of "bump icons" then becomes active,
- allowing you to choose which column of the table will replace the data which
- you type in. In such cases both the entries in the validation list proper
- and those in the replacement list are considered equally valid and either
- may be typed. e.g. in the case quoted above for the F.E. college database
- you could actually type in 'English Language and Literature' if you wished,
- instead of just 'ELL'. Powerbase would accept either, but the former will
- obviously take much longer to enter and you are far more likely to make a
- mistake (in which case Powerbase would object).
-
- Select the switch 'Link to table' and click on 'OK'. You will now see that
- the foreground colour of the linked field has changed from black to green.
- Place the caret in the field and click on 'List values' on the keypad. The
- validation table should be displayed.
-
- Displaying linked data
- ======================
- The final entry on the 'Validation' submenu is 'Show relations'. Powerbase
- makes no claim to be anything but a flat-file database, but effective use of
- validation tables does give it some of the advantages normally to be found
- only in a relational database. If you choose the 'Show relations' entry
- (so that it becomes ticked) you will find that clicking the over a data
- field which is linked to a validation table causes a small window to appear
- to the right of the keypad. This window lists all the data which is on the
- same row of the validation table as the linked item. As you edit the record,
- moving from field to field, this window is constantly updated. It disappears
- when the caret is in a non-linked field.
-
- You can also bring up this window (whether 'Show relations' is ticked or
- not) by double-clicking with SELECT on a linked field - very handy if coded
- data is being used and you encounter a code you've never met before.
-
- Displaying validation tables
- ============================
- When a table is linked to a field in the database record it may be displayed
- by placing the caret in the linked field and clicking on the keypad
- button 'List values' (keystroke equivalent f8). Alternatively, any table
- present in memory, whether linked to a data field or not, may be displayed
- by selecting it from the 'Display table' sub-menu (off the 'Validation'
- sub-menu). Clicking MENU over the table then offers a menu with entries
- enabling you to clear, save, print or sort the table.
-
- The validation table menu
- =========================
- Clear
- -----
- Removes all data from the table, leaving it blank. Since wiping out a table
- in this way is pretty drastic (and irrevocable) you will need 'Manager'
- level rights to do it, otherwise 'Clear' is shaded. Even so you are asked to
- confirm the operation before it actually takes place. When you close a
- database all the validation tables in memory are written to the disc so you
- will over-write your disc copy with the blank table.
-
- Save
- ----
- This leads to a 'Save' box in which the default pathname points to a
- directory called 'ValTables' inside the database application directory.
- Since that's where Powerbase expects to find the tables for a database you
- should normally accept this pathname by clicking on 'OK' or typing RETURN.
- Only if you are transferring tables from one database to another should you
- need to drag the icon to a filer window. All validation tables in memory
- are, in any case, saved to the 'ValTables' directory when you close the
- database or quit Powerbase and you can also make this happen at any time by
- clicking on 'Force update' on the keypad.
-
- Print
- -----
- Printing out the contents of a validation table (as opposed to printing a
- report containing data from a validation table) is done via this menu
- choice. The output appears in a window from which it may be saved as a text
- file (see 'Printing' - Output destination).
-
- Sort
- ----
- This will sort the table on the first column.
-
- Loading validation tables
- =========================
- Once a table is linked to a data field it will be automatically loaded when
- the database is opened. If not yet linked, however, the table won't be in
- memory unless you have just created it. To load the table choose 'Show table
- files' from the 'Validation' submenu. The contents of the 'ValTables'
- directory will be displayed and the required tables can dragged onto the
- record window (or simply double-clicked). As each table is dropped it will
- be displayed. N.B. Only one table at a time may be actually displayed.
-
- There may be times when the user wishes to use a validation table to hold
- some data, but doesn't wish to use it to validate input into a field or to
- link it to a field at all. How does one make sure the required table gets
- loaded? It is always possible to load a validation table once the database
- is open by using the procedure described in the previous paragraph, but
- there's a more elegant solution. By adding a "!" character to the end of the
- table's name you will cause Powerbase to load it whether any field is linked
- to it or not.
-
- Including validation table data in printouts
- ============================================
- Validation tables are commonly used to allow short codes to be entered in
- records but with a link to a more descriptive entry in another column of the
- table. If this is all you require then always put the data which makes up
- the actual validation list, i.e. the items which are allowed in the fields
- of the main record, into the first column of the table and set the link
- from the record field to this column (column 0). The more detailed
- "expanded" entry should then go in column 1. Printing with the 'Expand'
- switch in the 'Print options' window selected will then print the column 1
- instead of the column 0 entry.
-
- You can, however, include data from other columns of a table by displaying
- the table and clicking in the required columns with ADJUST, exactly like
- selecting main record fields for printing (see 'Printing'). It is immaterial
- which row you click on: only the column matters and the highlighting to show
- which columns are selected always appears in the first row. The columns
- selected in all tables are saved as part of a print selection and may
- therefore be retrieved for future use. As well as highlighting the required
- columns you will also need to select the 'Expand' switch as described above.
- Printed reports will then include all the data from the highlighted columns.
-
-
-
-